#include "Marshal.h"
#include "Marshal.impl.cc"

namespace noria
{
	class Marshal final : public IMarshal
	{
	public:
		virtual IReflectable* Box(int value) const override
		{
			return m_impl.Box(value);
		}
		virtual IReflectable* Box(long value) const override
		{
			return m_impl.Box(value);
		}
		virtual IReflectable* Box(double value) const override
		{
			return m_impl.Box(value);
		}
		virtual IReflectable* Box(bool value) const override
		{
			return m_impl.Box(value);
		}
		virtual IReflectable* Box(const char* value) const override
		{
			return m_impl.Box(value);
		}
		virtual IReflectable* Box(const wchar_t* value) const override
		{
			return m_impl.Box(value);
		}

		virtual void Unbox(const IReflectable& ref, int& value) const override
		{
			return m_impl.Unbox(ref, value);
		}
		virtual void Unbox(const IReflectable& ref, long& value) const override
		{
			return m_impl.Unbox(ref, value);
		}
		virtual void Unbox(const IReflectable& ref, double& value) const override
		{
			return m_impl.Unbox(ref, value);
		}
		virtual void Unbox(const IReflectable& ref, bool& value) const override
		{
			return m_impl.Unbox(ref, value);
		}
		virtual void Unbox(const IReflectable& ref, const char*& value) const override
		{
			return m_impl.Unbox(ref, value);
		}
		virtual void Unbox(const IReflectable& ref, const wchar_t*& value) const override
		{
			return m_impl.Unbox(ref, value);
		}
	public:
		virtual void Dispose() override
		{
			delete this;
		}
		virtual const IType* const GetType() const override
		{
			return GetMarshalType();
		}
		virtual IReflectable* Invoke(const char* name, IReflectable** args) override
		{
			// TODO:
			return nullptr;
		}
	private:
		MarshalImpl m_impl;
	private:
		friend const IType* const GetMarshalType();
		class Type final : public IType
		{
		public:
			virtual void Dispose() override
			{
			}
			virtual IReflectable* CreateInstance() const override
			{
				return new Marshal();
			}
			virtual const char* const GetName() const override
			{
				return "Marshal";
			}
			virtual const char* const GetFullName() const override
			{
				return "noria.Marshal";
			}
		};
	};

	const IType* const GetMarshalType()
	{
		static Marshal::Type type;
		return &type;
	}
}

